﻿/**
 * ...
 * @author sminutoli
 */
import com.dmotiko.general.*
import com.dmotiko.prune.*
import mx.transitions.easing.*;
import mx.transitions.*;
import mx.utils.*;
import flash.display.BitmapData;
 
class com.dmotiko.prune.FashionZoom extends Section
{
	private var mcPhoto:MovieClip;
	private var mcl:MovieClipLoader;
	public var mcClose:MovieClip;
	public var mcPrev:MovieClip;
	public var mcNext:MovieClip;
	
	private function initClip():Void {
		super.initClip();
		
		_x = 357;
		
		resetPhoto();
		
		mcl = new MovieClipLoader();
		mcl.addListener(this);
		
		mcClose.onRelease = function() {
			Site.getApp().getClips().getFashionZoom().hide();
		}
		
	}
	
	private function resetPhoto():Void
	{
		mcPhoto = createEmptyMovieClip( "mcPhoto", this.getNextHighestDepth() );
		mcPhoto.createEmptyMovieClip("img", 1);
		mcPhoto.createEmptyMovieClip("bitmap", 2);
	}
	
	private function onLoadInit(target):Void {
		//trace( "FashionZoom | onLoadInit = " + target );
		target._visible = false;
		
        var bmp:BitmapData = new BitmapData(
            target._width, 
            target._height, 
            true);

         mcPhoto.bitmap.attachBitmap(
            bmp, 
            1,
            "auto", 
            true);

         bmp.draw(target);
		
		show();
		
	}
	
	public function show():Void {
		super.show();
		Site.getApp().getClips().getShadowTop().show();
	}
	public function hide():Void {
		super.hide();
		Site.getApp().getClips().getShadowTop().hide();
	}
	
	private function hideEnd():Void {
		super.hideEnd();
		resetPhoto();
	}
	
	private function refreshData():Void {
		var _data = data;
		var root:FashionZoom = this;
		mcl.loadClip( data.big, mcPhoto.img );
		mcPrev.onRelease = function() {
			var img = _data.total[ _data.index - 1 ];
			if ( !img ) img = _data.total[ _data.total.length - 1 ];
			root.setData( img );
		}
		
		mcNext.onRelease = function() {
			var img = _data.total[ _data.index + 1 ];
			if ( !img ) img = _data.total[ 0 ];
			root.setData( img );
		}
	}
	
}